package com.shujia.Dao;

import com.shujia.JdbcUtil.JdbcUtil_plus;
import com.shujia.user.Weibo;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class weiboDao {
    public Weibo hostSearch(int id){
        Weibo weibo = null;
        Connection conn = JdbcUtil_plus.getConnection();
        try {
            PreparedStatement ps = conn.prepareStatement("select * from t_weibo where id=?");
            ps.setString(1,String.valueOf(id));
            ResultSet rs = ps.executeQuery();
            if(rs.next()){
                weibo = new Weibo();
                String text = rs.getString("text");
                weibo.setId(id);
                weibo.setText(text);
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }
        return weibo;
    }

}
